import { createRouter, createWebHistory } from 'vue-router'
// 暂时移除图标导入，使用emoji替代

// 布局组件
import Layout from '@/layout/index.vue'

// 路由配置
const routes = [
  // 首页重定向
  {
    path: '/',
    redirect: '/dashboard',
    hidden: true
  },
  
  // 仪表盘
  {
    path: '/dashboard',
    component: Layout,
    children: [
      {
        path: '',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '仪表盘', icon: '📊' }
      }
    ]
  },
  
  // 数据源管理
  {
    path: '/datasource',
    component: Layout,
    children: [
      {
        path: '',
        name: 'DatasourceList',
        component: () => import('@/views/datasource/list.vue'),
        meta: { title: '数据源管理', icon: '🗄️' }
      }
    ]
  },
  
  // 数据源操作页面 - 隐藏不在菜单显示
  {
    path: '/datasource/create',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'DatasourceCreate',
        component: () => import('@/views/datasource/form.vue'),
        meta: { title: '新增数据源' }
      }
    ]
  },
  {
    path: '/datasource/edit/:id',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'DatasourceEdit',
        component: () => import('@/views/datasource/form.vue'),
        meta: { title: '编辑数据源' },
        props: true
      }
    ]
  },
  
  // 同步任务管理
  {
    path: '/task',
    component: Layout,
    children: [
      {
        path: '',
        name: 'TaskList',
        component: () => import('@/views/task/list.vue'),
        meta: { title: '同步任务', icon: '🔗' }
      }
    ]
  },
  
  // 任务操作页面 - 隐藏不在菜单显示
  {
    path: '/task/create',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'TaskCreate',
        component: () => import('@/views/task/form.vue'),
        meta: { title: '新增任务' }
      }
    ]
  },
  {
    path: '/task/edit/:id',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'TaskEdit',
        component: () => import('@/views/task/form.vue'),
        meta: { title: '编辑任务' },
        props: true
      }
    ]
  },
  {
    path: '/task/log/:id',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'TaskLog',
        component: () => import('@/views/task/log.vue'),
        meta: { title: '任务日志' },
        props: true
      }
    ]
  },
  
  // 同步日志
  {
    path: '/log',
    component: Layout,
    children: [
      {
        path: '',
        name: 'LogList',
        component: () => import('@/views/log/list.vue'),
        meta: { title: '同步日志', icon: '📄' }
      }
    ]
  },
  
  // 日志详情页面 - 隐藏不在菜单显示
  {
    path: '/log/detail/:id',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'LogDetail',
        component: () => import('@/views/log/detail.vue'),
        meta: { title: '日志详情' },
        props: true
      }
    ]
  },
  
  // 统计分析
  {
    path: '/stats',
    component: Layout,
    redirect: '/stats/overview',
    meta: { title: '统计分析', icon: '📈' },
    children: [
      {
        path: 'overview',
        name: 'StatsOverview',
        component: () => import('@/views/stats/overview.vue'),
        meta: { title: '同步概览' }
      },
      {
        path: 'performance',
        name: 'StatsPerformance',
        component: () => import('@/views/stats/performance.vue'),
        meta: { title: '性能分析' }
      }
    ]
  },
  
  // 监控报警
  {
    path: '/monitor',
    component: Layout,
    redirect: '/monitor/realtime',
    meta: { title: '监控报警', icon: '🔔' },
    children: [
      {
        path: 'realtime',
        name: 'MonitorRealtime',
        component: () => import('@/views/monitor/realtime.vue'),
        meta: { title: '实时监控' }
      },
      {
        path: 'alert',
        name: 'MonitorAlert',
        component: () => import('@/views/monitor/alert.vue'),
        meta: { title: '报警记录' }
      }
    ]
  },
  
  // 假数据生成
  {
    path: '/fake-data',
    component: Layout,
    children: [
      {
        path: '',
        name: 'FakeDataGenerator',
        component: () => import('@/views/fake-data/index.vue'),
        meta: { title: '假数据生成', icon: '🛠️' }
      }
    ]
  },
  
  // 404页面
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/error/404.vue'),
    hidden: true
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router